<?php

/*
Plugin Name: Google Translate
Plugin URI: http://onemansblog.com/2007/03/25/google-translate-wordpress-plugin/
Description: Provides Google Translation in multiple languages. Has been tested with Internet Explorer, Firefox, Opera and also validates at the XHTML level. (Based on Scott Hough's <a href="http://www.scotthough.com/wordpress-translate/">WP Translate</a>.)
Version: 3.24.07
Author: John Pozadzides
Author URI: http://onemansblog.com 
*/

 function google_translate($vh) {
$currenturl = $_SERVER["PHP_SELF"];
if ( $_SERVER['QUERY_STRING'] <> '') {
   $currenturl .= "?" . $_SERVER['QUERY_STRING'];
 }

if ($vh == 1){
$vh1 = "<li>";
$vh2 = "</li>";
$c1 = "";
$c2 = "";
$ul1 = "<ul>";
$ul2 = "</ul>";
} elseif ($vh == 2){
$vh1 = " ";
$vh2 = " ";
$c1 = "<!-- ";
$c2 = " -->";
$ul1 = "";
$ul2 = "";
} else {
$vh1 = "<li>";
$vh2 = "</li>";
$c1 = "";
$c2 = "";
$ul1 = "<ul>";
$ul2 = "</ul>";
}

$currenturl = 'http://' . $_SERVER["SERVER_NAME"] . $currenturl;
$currenturl = str_replace(":", "%3A", $currenturl);
$currenturl = str_replace("/", "%2F", $currenturl);
$currenturl = str_replace("&", "%26", $currenturl);
?>
<? echo $ul1; ?>
<? echo $vh1; ?><a title="German" rel="nofollow" href="http://translate.google.com/translate?u=<?echo $currenturl;?>&amp;langpair=en%7Cde&amp;hl=en&amp;ie=UTF8"><img src="/wp-content/plugins/google-translate/images/germany.gif" width="22" height="15" alt="Translate to German" /><? echo $c1; ?>German<? echo $c2; ?></a><? echo $vh2; ?>
<? echo $vh1; ?><a title="Spanish" rel="nofollow" href="http://translate.google.com/translate?u=<?echo $currenturl;?>&amp;langpair=en%7Ces&amp;hl=en&amp;ie=UTF8"><img src="/wp-content/plugins/google-translate/images/spain.gif" width="22" height="15" alt="Translate to Spanish" /><? echo $c1; ?>Spanish<? echo $c2; ?></a><? echo $vh2; ?>
<? echo $vh1; ?><a title="French" rel="nofollow" href="http://translate.google.com/translate?u=<?echo $currenturl;?>&amp;langpair=en%7Cfr&amp;hl=en&amp;ie=UTF8"><img src="/wp-content/plugins/google-translate/images/france.gif" width="22" height="15" alt="Translate to French" /><? echo $c1; ?>French<? echo $c2; ?></a><? echo $vh2; ?>
<? echo $vh1; ?><a title="Italian" rel="nofollow" href="http://translate.google.com/translate?u=<?echo $currenturl;?>&amp;langpair=en%7Cit&amp;hl=en&amp;ie=UTF8"><img src="/wp-content/plugins/google-translate/images/italy.gif" width="22" height="15" alt="Translate to Italian" /><? echo $c1; ?>Italian<? echo $c2; ?></a><? echo $vh2; ?>
<? echo $vh1; ?><a title="Portuguese" rel="nofollow" href="http://translate.google.com/translate?u=<?echo $currenturl;?>&amp;langpair=en%7Cpt&amp;hl=en&amp;ie=UTF8"><img src="/wp-content/plugins/google-translate/images/portugal.gif" width="22" height="15" alt="Translate to Portuguese" /><? echo $c1; ?>Portuguese<? echo $c2; ?></a><? echo $vh2; ?>
<? echo $vh1; ?><a title="Japanese" rel="nofollow" href="http://translate.google.com/translate?u=<?echo $currenturl;?>&amp;langpair=en%7Cja&amp;hl=en&amp;ie=UTF8"><img src="/wp-content/plugins/google-translate/images/japan.gif" width="22" height="15" alt="Translate to Japanese" /><? echo $c1; ?>Japanese<? echo $c2; ?></a><? echo $vh2; ?>
<? echo $vh1; ?><a title="Korean" rel="nofollow" href="http://translate.google.com/translate?u=<?echo $currenturl;?>&amp;langpair=en%7Cko&amp;hl=en&amp;ie=UTF8"><img src="/wp-content/plugins/google-translate/images/korea.gif" width="22" height="15" alt="Translate to Korean" /><? echo $c1; ?>Korean<? echo $c2; ?></a><? echo $vh2; ?>
<? echo $vh1; ?><a title="Russian" rel="nofollow" href="http://translate.google.com/translate?u=<?echo $currenturl;?>&amp;langpair=en%7Cru&amp;hl=en&amp;ie=UTF8"><img src="/wp-content/plugins/google-translate/images/russia.gif" width="22" height="15" alt="Translate to Russian" /><? echo $c1; ?>Russian<? echo $c2; ?></a><? echo $vh2; ?>
<? echo $vh1; ?><a title="Chinese Tradational" rel="nofollow" href="http://translate.google.com/translate?u=<?echo $currenturl;?>&amp;langpair=en%7Czh-TW&amp;hl=en&amp;ie=UTF8"><img src="/wp-content/plugins/google-translate/images/china.gif" width="22" height="15" alt="Translate to Chinese" /><? echo $c1; ?>Chinese<? echo $c2; ?></a><? echo $vh2; ?>
<? echo $ul2; ?>
<?php
}
?>
